package edu.colorado.cs.correll.cudroplet.shaperecognition;

import processing.core.PShape;

/**
 * Provides a test environment with a border
 * 
 * @author charlesdietrich
 * 
 */
public class SimpleEnvironmentMap extends EnvironmentMap {
	ShapeRecognition shapeRecognition;
	PlacedShape[] placedShapes;
	int width;
	int height;
	int border;
	PShape[] shapes;

	public SimpleEnvironmentMap(ShapeRecognition shapeRecognition,
			PlacedShape[] placedShapes, int width, int height, int border) {
		this.shapeRecognition = shapeRecognition;
		this.placedShapes = placedShapes;
		this.width = width;
		this.height = height;
		this.border = border;
		shapes = new PShape[placedShapes.length];
		// load the shapes
		for (int i = 0; i < shapes.length; i++) {
			shapes[i] = shapeRecognition.loadShape(placedShapes[i].name
					+ ".svg");
		}
	}

	public void draw() {
		shapeRecognition.background(255, 0, 0);
		shapeRecognition.noStroke();
		shapeRecognition.fill(0, 255, 0);
		shapeRecognition.rect(border, border, shapeRecognition.width - border
				* 2, shapeRecognition.height - border * 2);

		for (int i = 0; i < shapes.length; i++) {
			shapeRecognition.shape(shapes[i], border
					+ placedShapes[i].position.x, border
					+ placedShapes[i].position.y, SHAPE_DIM, SHAPE_DIM);
		}
	}
}